#include "InstructionsForUse.h"

InstructionsForUse::InstructionsForUse(QWidget *parent)
	: QWidget(parent)
{
	this->setWindowIcon(QIcon("Image\\运动会.svg"));
	QPixmap pixmap("Image\\光标.svg");
	pixmap = pixmap.scaled(30, 24, Qt::KeepAspectRatio);
	QCursor cursor(pixmap);
	this->setCursor(cursor);

	ui.setupUi(this);
}

InstructionsForUse::~InstructionsForUse()
{

}
void InstructionsForUse::paintEvent(QPaintEvent* event) {
	QPainter painter(this);
	QString imagePath = "image\\背景3.jpg";

	// 检查路径是否存在
	if (!QFile::exists(imagePath)) {
		qDebug() << "图片文件不存在：" << imagePath;
	}
	else {
		QPixmap bkgnd(imagePath);
		if (bkgnd.isNull()) {
			qDebug() << "无法加载图片：" << imagePath;
			painter.fillRect(rect(), QColor("#2c3e50"));

			painter.setPen(Qt::white);
			painter.drawText(rect(), Qt::AlignCenter, "背景加载失败");
			return;
		}
		// 确认窗口有效尺寸
		if (width() <= 0 || height() <= 0) {
			qDebug() << "无效窗口尺寸：" << size();
			return;
		}

		// 高质量缩放
		bkgnd = bkgnd.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
		painter.setOpacity(0.7);  //0.7
		painter.drawPixmap(0, 0, bkgnd);
	}
}
